<?php

/**
 * sfWidgetFormSchemaFormatterExt.
 *
 * @package    flexiwik
 * @subpackage widget
 * @author     Jonathan Olger Nieto Lajo <jonathan_nieto@hotmail.com>
 */
class sfWidgetFormSchemaFormatterExt extends sfWidgetFormSchemaFormatter
{
  protected
    $rowFormat                 = "<div>\n  
                                    %label%\n  
                                    %field%%help%%hidden_fields%\n
                                  </div>\n",
    
    //$errorRowFormat            = '',
    //$errorRowFormat            = "<div id=\"errorExplanation\" class=\"errorExplanation\" style=\"font-color:red\">\n%errors%</div>/n",
    //$errorListFormatInARow     = "  <ul class=\"error_list\">\n%errors%  </ul>\n",
    //$errorListFormatInARow     = "  <div id=\"errorExplanation\" class=\"errorExplanation\" style=\"font-color:red\">\n<li>%errors%</li></div>\n",
   // $errorRowFormatInARow      = "    <li>%error%</li>\n",
    $helpFormat                = "<a href=\"#\" onmouseover=\"showtip(\'%help%\')\" onmouseout=\"hidetip()\">[?]</a>",
    //'<br />%help%',
    $namedErrorRowFormatInARow = "%error%<br>\n",
    $decoratorFormat           = "%content%";
    //$decoratorFormat           = "<table id=\"crud_form\">\n  %content%</table>";

  public function formatRowExt($label, $field, $errors = array(), $help = '', $hiddenFields = null, $name)
  {
    return strtr
           (
             $this->getRowFormat(),
             array
             (
               '%class%'         => strpos($label, '*') ? ' class="required"' : '',
               '%label%'         => $label,
               '%field%'         => has_slot($name) ? get_slot($name) : $field,
               '%help%'          => $this->formatHelp($help),
               '%hidden_fields%' => is_null($hiddenFields) ? '%hidden_fields%' : $hiddenFields,
             )
           );
  }
}
